// Problem: P1036 [NOIP2002 普及组] 选数
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P1036
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<iostream>
#include<string.h>
#include<math.h>
using namespace std;

int n,k,a[21];
long long ans;
bool check(int x)
{
	if(x==1) return false;
	for(int i=2;i<=sqrt(x);++i)
	{
		if(x%i==0) return false;
	}
	return true;
}

void dfs(int m,int sum,int pos)
{
	if(m==k)
	{
		if(check(sum)) ++ans;
		return;
	}
	for(int i=pos;i<n;++i)
	{
		dfs(m+1,sum+a[i],i+1);
	}
	return ;
}

int main()
{
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;++i)
		cin>>a[i];

	dfs(0,0,0);
	cout<<ans;
	return 0;
}